package com.cfpl.config;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @Auther: LYP
 * @Date: 2023/10/14 - 12:48
 * @Description: com.cfpl.admin_service.config
 * @version: 1.0
 */
@Component //项目运行时就注入Spring容器
public class RedisUtils {
    @Resource
    private StringRedisTemplate redis;

    //赋值一个静态的redisTemplate
    public static StringRedisTemplate stringRedisTemplate;

    @PostConstruct //此注解表示构造时赋值
    public void redisTemplate() {
        stringRedisTemplate = this.redis;
    }
}

